package com.guchenbo.spark.demo;

import com.google.common.collect.Lists;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author guchenbo
 * @date 2022/3/2
 */
public class FlatMap {

  public static void main(String[] args) {
    List<String> list = Lists.newArrayList("a b c d", "1 2 3 4");
    list.stream().map(s -> s.split(" ")).collect(Collectors.toList())
        .forEach(System.out::println);


    list.stream().flatMap(s -> Arrays.stream(s.split(" "))).collect(Collectors.toList())
        .forEach(System.out::println);
  }
}
